package com.cn.shop.service.impl;

import com.cn.shop.dao.HomeDao;
import com.cn.shop.entity.home.Activity;
import com.cn.shop.entity.home.Notice;
import com.cn.shop.entity.home.Shop;
import com.cn.shop.service.HomeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 首页接口
 *
 * @author suhao
 * @time 2018-01-21
 * @email suhao755@gmail.com
 */
@Service
public class HomeServiceImpl implements HomeService{
    private static Logger log = LoggerFactory.getLogger(HomeServiceImpl.class);
    @Autowired
    private HomeDao homeDao;
    @Override
    public List<Shop> getShopLists(String longitude, String latitude) {
        List<Shop> listShop = homeDao.getShopLists(longitude, latitude);
        for (int i = 0; i < listShop.size(); i++) {
            int shopId = listShop.get(i).getShopId();
            List<Activity> listActivity = homeDao.getActivityByShopId(shopId);
            listShop.get(i).setActivityList(listActivity);
        }
        log.info(listShop + "<<<listShop<<<");
        return listShop;
    }

    @Override
    public List getNoticeLists() {
        List<Notice> noticeList = homeDao.getNoticeLists();
        return noticeList;
    }
}
